<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 创建对象的三种方式
        // 方式一：通过new Object()创建对象
        var obj = new Object();
        // 方式二：通过对象字面量创建对象
        var obj2 = {};
        // 方式三：通过构造函数创建对象
        // 构造函数的首字母要大写
        function Star(name, age) {
            this.name = name;
            this.age = age;
            this.sing = function() {
                console.log(this.name + 'sing a song');
            }
        }
        var adele = new Star('阿黛尔', 20)
        adele.sing()
    </script>
</body>

</html>